package name.marz.to.go.btree.node;

public class NodeFactory {
//	private static NodeFactory the_instance = new NodeFactory();
	public static final int MINIMUM_KEYS = 2;
	
	private NodeFactory() {
	}
	
//	public static NodeFactory getFactory() {
//		return the_instance;
//	}
	
	public static Node createNode(String className, int maxKeys ) {
		if ( maxKeys < MINIMUM_KEYS ) throw new IllegalArgumentException("The number of keys should be "+MINIMUM_KEYS+" or more. ");
		if ( maxKeys % 2 != 0 ) throw new IllegalArgumentException("The number of keys should be the even number. ");
		Node node = null;
		try {
			node = (Node)Class.forName(className).newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		node.setMaxKeys(maxKeys);
		return node;
	}
	
}
